﻿using ECMS.Infrastructure.Domain;
using System;

namespace ECMS.Domain.Models
{
    /// <summary>
    /// 用户
    /// </summary>
    public class SysUser : EntityCore
    {
        /// <summary>
        /// 登录名
        /// </summary>
        public string LoginName { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        public string Password { get; set; }
        /// <summary>
        /// 验证码
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 真实姓名
        /// </summary>
        public string RealName { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        public string Mobile { get; set; }
        /// <summary>
        /// 是否锁定
        /// </summary>
        public bool IsLock { get; set; }
        /// <summary>
        /// 锁定时间
        /// </summary>
        public DateTime LockTime { get; set; } =
        new DateTime(1900, 1, 1);
        /// <summary>
        /// 解锁时间
        /// </summary>
        public DateTime UnLockTime { get; set; } =
        new DateTime(1900, 1, 1);
        /// <summary>
        /// 最后登录时间
        /// </summary>
        public DateTime LastLoginTime { get; set; }
        /// <summary>
        /// 登录的版本号
        /// </summary>
        public string Version { get; set; }
        /// <summary>
        /// 登录IP
        /// </summary>
        public string LoginIP { get; set; }
        
        protected override void Validate()
        {
            //if (string.IsNullOrEmpty(Mobile))
            //    AddBrokenRule(new BusinessRule(nameof(Mobile), "手机号不能为空."));
            if (string.IsNullOrEmpty(Password))
                AddBrokenRule(new BusinessRule(nameof(Password), "登录密码不能为空."));
        }
    }
}
